/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Utilities;

import AccountDTO.Account;
import Controller.LoginController;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.util.*;

/**
 *
 * @author Phuong Giang
 */
public class ChatSession implements HttpSessionListener {

    @Override
    public void sessionCreated(HttpSessionEvent event) {
        System.out.println("session created at : " + new Date() );
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent event) {
        HttpSession session = event.getSession();
        System.out.println("session created at : " + new Date());
        Account acc = (Account) session.getAttribute("USER");
        if (acc != null) {
            LoginController.onlineList.remove(acc.getUsername());
        }
    }
}
